
#include "common.h"
#include "AndNode.h"
#include "OrNode.h"

bool InstanceTreeType::InputFromStream(istream& inStream)
{
	if (!(inStream>>Root>>Width>>Height)) return false;
	int i, tn;
	if (!(inStream>>tn)) return false;
	AndNodes.resize(tn); for ( i = 0; i < tn; ++i ) if (!(AndNodes[i].InputFromStream(inStream))) return false;
	if (!(inStream>>tn)) return false;
	OrNodes.resize(tn); for ( i = 0; i < tn; ++i ) if (!(OrNodes[i].InputFromStream(inStream))) return false;
	return true;
}

void InstanceTreeType::OutputToStream(ostream& outStream) const
{
	outStream<<Root<<"\t"<<Width<<"\t"<<Height<<endl<<endl;
	int i, tn;
	outStream<<(tn = (int)AndNodes.size())<<endl;
	for ( i = 0; i < tn; ++i ) AndNodes[i].OutputToStream(outStream);
	outStream<<(tn = (int)OrNodes.size())<<endl;
	for ( i = 0; i < tn; ++i ) OrNodes[i].OutputToStream(outStream);
}

